#include <iostream>

using namespace std;

int dx[] = {0 , 1, 0, -1};
int dy[] = {1 , 0, -1, 0};

const int N = 10;
int arr[N][N];

int x = 1, y = 1;
int pos = 0;

int main()
{
	int n; cin >> n;
	int cnt = 1;
	
	while(cnt <= n*n)
	{
		arr[x][y] = cnt;
		int a = x+dx[pos];
		int b = y+dy[pos];
		if (a > n || b > n || a < 1 || b < 1 || arr[a][b])
		{
			pos = (pos+1)%4;
			a = x + dx[pos], b = y + dy[pos]; 
		}
		x = a, y = b;
		cnt++;
	}
	
	
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			printf("%3d", arr[i][j]);
		}
		cout << endl;
	}
	
	return 0;
} 
